﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using CommonTools;
using FreeSql.DataAnnotations;

namespace shop.Model
{
    public class JUser : IUser, IFastTree
    {

        /// <summary> 代码 </summary>
		[Column(IsPrimary = true, IsIdentity = true)]
        public int DocID { get; set; }

        /// <summary> 制单人 </summary>
        [Column(StringLength =50)]
        public string Biller { get; set; }

        /// <summary> 制单日期 </summary>
        public DateTime? BillerDate { get; set; }

        /// <summary> 员工ID </summary>
        [Column(StringLength = 800, IsNullable = false)]
        public string Dept { get; set; }

        /// <summary> 部门权限 </summary>
        public int? EmpID { get; set; } = 0;

        /// <summary> 名称 </summary>
        [Column(StringLength = 30, IsNullable = false)]
        public string Name { get; set; }

     

        /// <summary> 密码 </summary>
        [VarChar(32)]
        public string Password { get; set; }

        public bool? Isdel { get; set; } = false;

        public DateTime? IsdelDate { get; set; }

        public bool? Isrole { get; set; }

        public bool? IsSaler { get; set; }

        public DateTime? LastLoginTime { get; set; }

        [Column(StringLength = 4000)]
        public string ProfileJson { get; set; }

        /// <summary> 登录方式 </summary>
        [Column(StringLength = 30, IsNullable = false)]
        public string SafeMode { get; set; }


        /// <summary>
        /// 角色
        /// </summary>
        [Column(IsIgnore =true)]
        public string Role { set; get; }

        /// <summary> 新密码 </summary>
        [Column(IsIgnore =true)]
        public string NewUserPwd { set; get; }

        /// <summary>
        /// 用户权限列表, 只在当前用户使用此字段
        /// </summary>
        [Column(IsIgnore =true)]
        public List<string> Permissions { set; get; }


        /// <summary> 代码 </summary>
        [Column(IsIgnore =true)]
        public int Code { get => this.DocID; set => this.DocID = value; }

        [Column(IsIgnore =true)]
        public string NodeText => this.Name;


        #region 登录信息


        [Column(IsIgnore =true)]
        public string ComputerInfo { set; get; }
        [Column(IsIgnore =true)]
        public string Ip { set; get; }
        [Column(IsIgnore =true)]
        public string Mac { set; get; }

        #endregion

        /// <summary> 用户配置文件 </summary>
        [Column(IsIgnore =true)]
        public JUserProfile Profile { set; get; }

        [Column(IsIgnore =true)]
        string IFastTree.Code => DocID.ToString();
    }

    /// <summary> 用户配置文件 </summary>
    [Table(DisableSyncStructure = true)]
    public class JUserProfile
    {
        /// <summary> 凭证保存后立即新增 </summary>
        public bool AddNewVouchersAfterSaving { set; get; } = false;



    }




}
